#include <stdio.h>
#include <math.h>
int p=0;
int PrimeDivi(int n,int a[100]);
int IsPrime(unsigned int m);
int main()
{
    int n;
    int a[100];
    printf("please input a number:");
    scanf("%d",&n);
    PrimeDivi(n,a);
    printf("the number can be divided into prime numbers as following:\n");
    int i;
    for(i=0;i<=p;i++)
    {
        printf("%d  ",a[i]);
    }
    return 0;
}
int PrimeDivi(int n,int a[100])
{
    if(IsPrime(n))
    {
        a[p]=n;
        return 0;
    }
    else
    {
        int i;
        for(i=2;i<n;i++)
        {
            if(0==n%i)
            {
                n=n/i;
                a[p]=i;
                p++;
                break;
            }
        }
        return PrimeDivi(n,a);
    }
}
int IsPrime(unsigned int m)
{
    int i;
    if(0==m)
    {
        printf("Wrong input!It's meaningless to judge whether 0 is a prime!\n");
        exit(0);
    }
    if(1==m)
    {
        printf("Wrong input!It's meaningless to judge whether 1 is a prime!\n");
        exit(0);
    }
    for(i=2;i<=sqrt(m);i++)
    {
        if(0==m%i)
        {
            return 0;
        }
    }
    return 1;
}
